package com.keshe.order.service.impl;

import org.springframework.stereotype.Service;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.keshe.common.utils.PageUtils;
import com.keshe.common.utils.Query;

import com.keshe.order.dao.CommodityDao;
import com.keshe.order.entity.CommodityEntity;
import com.keshe.order.service.CommodityService;


@Service("commodityService")
public class CommodityServiceImpl extends ServiceImpl<CommodityDao, CommodityEntity> implements CommodityService {



    @Override
    public PageUtils getOrderCommodity(Map<String, Object> params) {
        String orderId = (String) params.get("orderId");
        String isReturn = (String) params.get("isReturn");

        QueryWrapper<CommodityEntity> wrapper = new QueryWrapper<>();
        wrapper
                .eq(StringUtils.isNotBlank(orderId), "order_id", orderId)
                .eq(StringUtils.isNotBlank(isReturn), "is_return", isReturn);

        IPage<CommodityEntity> page = this.page(
                new Query<CommodityEntity>().getPage(params), wrapper);

        return new PageUtils(page);
    }



    @Override
    public PageUtils SearchQueryPage(Map<String, Object> params) {
        IPage<CommodityEntity> page = this.page(
                new Query<CommodityEntity>().getPage(params),
                new QueryWrapper<CommodityEntity>()
        );

        return new PageUtils(page);
    }
}
